package com.koron.order.common.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.common.bean.po.OrderAllPo;
import com.koron.order.common.bean.query.OrderAllQuery;
import com.koron.order.common.bean.query.OrderNoMergeQuery;
import com.koron.order.common.bean.vo.OrderAllVo;
import com.koron.order.common.bean.vo.OrderNoMergeVo;
import com.koron.order.common.service.OrderLineAllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * (OrderAll)表控制层
 * LineFirst            线路第一种工作票
 * LineSecond           线路第二种工作票
 * line_defect          缺陷工单
 * other_patrol         其他巡视单
 * risk                 风险管控单
 * risk_duty            看护值守单
 * satellite_check      卫星巡视风险核实工单
 * monitorChange_check  卫星监测变化核实工单
 * uavRisk_check        无人机巡视风险核实工单
 * special_scene        特殊现场巡视
 * special_video        特殊视频巡视
 * timing_scene         定期现场巡视
 * timing_video         定期视频巡视
 *
 * @author zhouj
 * @since 2021-10-13 16:52:34
 */
@Api(tags = "工单关联(视图)")
@RestController
@RequestMapping("/orderLineAll/")
public class OrderLineAllController {

    @Autowired
    private OrderLineAllService orderLineAllService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("queryById")
    public Response<OrderAllPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryById", OrderAllPo.class, id));
    }

    @ApiOperation(value = "不分页查询列表")
    @GetMapping("queryList")
    public Response<List> queryList(OrderAllQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryList", List.class, query));
    }

    @ApiOperation(value = "分页查询列表")
    @GetMapping("queryPageList")
    public Response<PageInfo<OrderAllVo>> queryPageList(OrderAllQuery query, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryPageList", PageInfo.class, query, pageQuery));
    }

    @ApiOperation(value = "未合并-不分页查询列表")
    @GetMapping("queryListNoMerge")
    public Response<List<OrderNoMergeVo>> queryListNoMerge(OrderNoMergeQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryListNoMerge", List.class, query));
    }

    @ApiOperation(value = "未合并-分页查询列表")
    @GetMapping("queryPageListNoMerge")
    public Response<PageInfo<OrderNoMergeVo>> queryPageListNoMerge(OrderNoMergeQuery query, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryPageListNoMerge", PageInfo.class, query, pageQuery));
    }

    @ApiOperation(value = "根据日期查询某个月的任务,用来标注工作历")
    @GetMapping("queryMonthTaskList")
    public Response<List> queryMonthTaskList(OrderAllQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryMonthTaskList", List.class, query));
    }

    @ApiOperation(value = "根据日期查询某天的任务")
    @GetMapping("queryDayTaskList")
    public Response<Map> queryDayTaskList(OrderAllQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderLineAllService, "queryDayTaskList", Map.class, query));
    }

}
